package com.aerotechnic.util;

import org.springframework.beans.factory.annotation.Autowired;

import com.aerotechnic.entities.MacroTacheBiblio;
import com.aerotechnic.service.interfaces.MacroTacheBiblioBoIn;

public class Convertor {
	
	@Autowired
	private MacroTacheBiblioBoIn macBo;
	
	public MacroTacheBiblio fromMacBibHelper2MacBib(MaccroTacheBibHelper macHelper){
		
		System.out.println("MaccroTacheHelper=====> "+macHelper);
		MacroTacheBiblio mac= new MacroTacheBiblio();
		mac.setDescription(macHelper.getDesc());
		mac.setIntitule(macHelper.getIntitule());
		
		MacroTacheBiblio pred = null;
		MacroTacheBiblio succ = null;
		
		// fetching pred and succ from the database basing on ids
		
		String predId=macHelper.getPred();
		String succId=macHelper.getSucc();
		
		if(! predId.equals("")){
			pred = macBo.findByID(Integer.parseInt(predId));
		}
		
		if(! succId.equals("")){
			succ = macBo.findByID(Integer.parseInt(succId));
		}
		
		mac.setPred(pred);
		mac.setSucc(succ);
		
		return mac;
	}
	
//	public EventBis fromEvent2EventBis(Event){
//		
//		return null;
//	}

}
